package com.yanq.liancar.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanq.liancar.R;
import com.yanq.liancar.bean.CouponBean;

import java.util.List;

public class CouponAdapter extends BaseQuickAdapter<CouponBean.DataBean, BaseViewHolder> {
    public CouponAdapter(int layoutResId, @Nullable List<CouponBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CouponBean.DataBean item) {
        helper.setText(R.id.tv_name, item.getService_name())
                .setText(R.id.tv_content, item.getService_content())
                .setText(R.id.tv_Termofvalidity, item.getIndate_start() + "-" + item.getIndate_end());
        //                .addOnClickListener(R.id.img_statu);
        RelativeLayout relativeLayout = helper.getView(R.id.rl_bg);
        ImageView imageView = helper.getView(R.id.img_statu);

        if (item.getService_status() == 0) {
            relativeLayout.setBackground(mContext.getResources().getDrawable(R.mipmap.coupon2));
            imageView.setImageResource(R.mipmap.lijishiyong);
            helper.addOnClickListener(R.id.img_statu);
        } else if (item.getService_status() == 1) {
            relativeLayout.setBackground(mContext.getResources().getDrawable(R.mipmap.coupon3));
            imageView.setImageResource(R.mipmap.ysy);
        } else {
            relativeLayout.setBackground(mContext.getResources().getDrawable(R.mipmap.coupon1));
            imageView.setImageResource(R.mipmap.ygq);
        }
    }
}
